﻿Imports System.Data.SqlClient

Public Class clsNominaDetalle
    Private mintcIdDetalle As Integer
    Private mintcIdNomina As Integer
    Private mintcIdEmpleado As Integer
    Private mstrcCodigo As String
    Private mstrcNombre As String
    Private mdblcIngreso As Double
    Private mdblcDias As Double
    Private mdblcSueldo As Double
    Private mdblcAyuda As Double
    Private mdblcComedor As Double
    Private mdblcHoras As Double
    Private mdblcDeporte As Double
    Private mdblcPuntualidad As Double
    Private mdblcAsistencia As Double
    Private mdblcGratificacion As Double
    Private mdblcPercepciones As Double
    Private mdblcISR As Double
    Private mdblcIMSS As Double
    Private mdblcInfonavit As Double
    Private mdblcFonacot As Double
    Private mdblcDeducciones As Double
    Private mdblcTotal As Double
    Public Property cIdDetalle() As Integer
        Get
            Return mintcIdDetalle
        End Get
        Set(ByVal value As Integer)
            mintcIdDetalle = value
        End Set
    End Property
    Public Property cIdNomina() As Integer
        Get
            Return mintcIdNomina
        End Get
        Set(ByVal value As Integer)
            mintcIdNomina = value
        End Set
    End Property
    Public Property cIdEmpleado() As Integer
        Get
            Return mintcIdEmpleado
        End Get
        Set(ByVal value As Integer)
            mintcIdEmpleado = value
        End Set
    End Property
    Public Property cCodigo() As String
        Get
            Return mstrcCodigo
        End Get
        Set(ByVal value As String)
            mstrcCodigo = value
        End Set
    End Property
    Public Property cNombre() As String
        Get
            Return mstrcNombre
        End Get
        Set(ByVal value As String)
            mstrcNombre = value
        End Set
    End Property
    Public Property cIngreso() As Double
        Get
            Return mdblcIngreso
        End Get
        Set(ByVal value As Double)
            mdblcIngreso = value
        End Set
    End Property
    Public Property cDias() As Double
        Get
            Return mdblcDias
        End Get
        Set(ByVal value As Double)
            mdblcDias = value
        End Set
    End Property
    Public Property cSueldo() As Double
        Get
            Return mdblcSueldo
        End Get
        Set(ByVal value As Double)
            mdblcSueldo = value
        End Set
    End Property
    Public Property cAyuda() As Double
        Get
            Return mdblcAyuda
        End Get
        Set(ByVal value As Double)
            mdblcAyuda = value
        End Set
    End Property
    Public Property cComedor() As Double
        Get
            Return mdblcComedor
        End Get
        Set(ByVal value As Double)
            mdblcComedor = value
        End Set
    End Property
    Public Property cHoras() As Double
        Get
            Return mdblcHoras
        End Get
        Set(ByVal value As Double)
            mdblcHoras = value
        End Set
    End Property
    Public Property cDeporte() As Double
        Get
            Return mdblcDeporte
        End Get
        Set(ByVal value As Double)
            mdblcDeporte = value
        End Set
    End Property
    Public Property cPuntualidad() As Double
        Get
            Return mdblcPuntualidad
        End Get
        Set(ByVal value As Double)
            mdblcPuntualidad = value
        End Set
    End Property
    Public Property cAsistencia() As Double
        Get
            Return mdblcAsistencia
        End Get
        Set(ByVal value As Double)
            mdblcAsistencia = value
        End Set
    End Property
    Public Property cGratificacion() As Double
        Get
            Return mdblcGratificacion
        End Get
        Set(ByVal value As Double)
            mdblcGratificacion = value
        End Set
    End Property
    Public Property cPercepciones() As Double
        Get
            Return mdblcPercepciones
        End Get
        Set(ByVal value As Double)
            mdblcPercepciones = value
        End Set
    End Property
    Public Property cISR() As Double
        Get
            Return mdblcISR
        End Get
        Set(ByVal value As Double)
            mdblcISR = value
        End Set
    End Property
    Public Property cIMSS() As Double
        Get
            Return mdblcIMSS
        End Get
        Set(ByVal value As Double)
            mdblcIMSS = value
        End Set
    End Property
    Public Property cINFONAVIT() As Double
        Get
            Return mdblcInfonavit
        End Get
        Set(ByVal value As Double)
            mdblcInfonavit = value
        End Set
    End Property
    Public Property cFONACOT() As Double
        Get
            Return mdblcFonacot
        End Get
        Set(ByVal value As Double)
            mdblcFonacot = value
        End Set
    End Property
    Public Property cDeducciones() As Double
        Get
            Return mdblcDeducciones
        End Get
        Set(ByVal value As Double)
            mdblcDeducciones = value
        End Set
    End Property
    Public Property cTotal() As Double
        Get
            Return mdblcTotal
        End Get
        Set(ByVal value As Double)
            mdblcTotal = value
        End Set
    End Property
   
    Public Sub New()
        mintcIdDetalle = 0
        mintcIdNomina = 0
        mintcIdEmpleado = 0
        mstrcCodigo = ""
        mstrcNombre = ""
        mdblcIngreso = 0
        mdblcDias = 0
        mdblcSueldo = 0
        mdblcAyuda = 0
        mdblcComedor = 0
        mdblcHoras = 0
        mdblcDeporte = 0
        mdblcPuntualidad = 0
        mdblcAsistencia = 0
        mdblcGratificacion = 0
        mdblcPercepciones = 0
        mdblcISR = 0
        mdblcIMSS = 0
        mdblcInfonavit = 0
        mdblcFonacot = 0
        mdblcDeducciones = 0
        mdblcTotal = 0
    End Sub
    Public Sub Borrar()
        Call SetSqlCitra("Delete From NominaDetalle Where IdNomina = " & cIdNomina)
    End Sub
    Public Sub Insertar()
        Dim sql As String = "Insert Into NominaDetalle (" & _
                            "IdDetalle," & _
                            "IdNomina," & _
                            "IdEmpleado," & _
                            "Codigo," & _
                            "Nombre," & _
                            "Ingreso," & _
                            "Dias," & _
                            "Sueldo," & _
                            "Ayuda," & _
                            "Comedor," & _
                            "Horas," & _
                            "Deporte," & _
                            "Puntualidad," & _
                            "Asistencia," & _
                            "Gratificacion," & _
                            "Percepciones," & _
                            "ISR," & _
                            "IMSS," & _
                            "Infonavit," & _
                            "Fonacot," & _
                            "Deducciones," & _
                            "Total)" & _
                            "VALUES (" & _
                            "@IdDetalle," & _
                            "@IdNomina," & _
                            "@IdEmpleado," & _
                            "substring(@Codigo,1,20)," & _
                            "substring(@Nombre,1,200)," & _
                            "@Ingreso," & _
                            "@Dias," & _
                            "@Sueldo," & _
                            "@Ayuda," & _
                            "@Comedor," & _
                            "@Horas," & _
                            "@Deporte," & _
                            "@Puntualidad," & _
                            "@Asistencia," & _
                            "@Gratificacion," & _
                            "@Percepciones," & _
                            "@ISR," & _
                            "@IMSS," & _
                            "@Infonavit," & _
                            "@Fonacot," & _
                            "@Deducciones," & _
                            "@Total)"

        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("IdDetalle", mintcIdDetalle)
        Command.Parameters.AddWithValue("IdNomina", mintcIdNomina)
        Command.Parameters.AddWithValue("IdEmpleado", mintcIdEmpleado)
        Command.Parameters.AddWithValue("Codigo", mstrcCodigo)
        Command.Parameters.AddWithValue("Nombre", mstrcNombre)
        Command.Parameters.AddWithValue("Ingreso", mdblcIngreso)
        Command.Parameters.AddWithValue("Dias", mdblcDias)
        Command.Parameters.AddWithValue("Sueldo", mdblcSueldo)
        Command.Parameters.AddWithValue("Ayuda", mdblcAyuda)
        Command.Parameters.AddWithValue("Comedor", mdblcComedor)
        Command.Parameters.AddWithValue("Horas", mdblcHoras)
        Command.Parameters.AddWithValue("Deporte", mdblcDeporte)
        Command.Parameters.AddWithValue("Puntualidad", mdblcPuntualidad)
        Command.Parameters.AddWithValue("Asistencia", mdblcAsistencia)
        Command.Parameters.AddWithValue("Gratificacion", mdblcGratificacion)
        Command.Parameters.AddWithValue("Percepciones", mdblcPercepciones)
        Command.Parameters.AddWithValue("ISR", mdblcISR)
        Command.Parameters.AddWithValue("IMSS", mdblcIMSS)
        Command.Parameters.AddWithValue("Infonavit", mdblcInfonavit)
        Command.Parameters.AddWithValue("Fonacot", mdblcFonacot)
        Command.Parameters.AddWithValue("Deducciones", mdblcDeducciones)
        Command.Parameters.AddWithValue("Total", mdblcTotal)


        cnConn.Open()
        Dim RowsAffected As Integer
        Try
            RowsAffected = Command.ExecuteNonQuery
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Aviso")
        End Try

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible insertar la evaluacion", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub
End Class
